
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/cglist.css"/>
    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/add.css"/>

    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/cg_info.css"/>
    <script type="text/javascript" src="/plan/caigou/js/jquery.1.9.1.js" ></script>
    <script type="text/javascript" src="/plan/caigou/js/layer.js" ></script>
    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/layer.css"/>

    <script type="text/javascript" src="/plan/caigou/js/rem.js" ></script>
    <title>退货单详情</title>
</head>
<style>
    #add1{display: block}
    #add3{display: none}
    .cglist li p.cginfo{
        height: .38rem;
        padding-top: .2rem;
    }
</style>
<section id="add1">
    <div>
        <ul class="cglist">
            <li>

                <p class="number">
                    <span class="num_left">{$info['supplier']}</span>
                    {$info['status_text']}
                </p>
                <p class="cginfo">
                    <span>单据编号</span>{$info['order_id']}
                </p>
                {notempty name="purinfo"}
                <p class="cginfo">
                    <span>关联单号</span>{$purinfo}
                </p>
                {/notempty}
                <p class="cginfo">
                    <span>退货人员</span>{$info['username']}
                </p>
                <p class="cginfo">
                    <span style="float: left;">单据备注</span>
                    <span style="width: 77%;display: inline-block;color: #333;">{$info['mark']}</span>
                </p>

            </li>
        </ul>
        <div class="jiesuan">
            <p class="title">退货明细</p>

            <p class="info">总数量<span>{$info['total']} ( {$info['count']}种 )</span></p>
            <p class="info">退货金额合计<span>¥{:number_format($info['total_money'],2,".",",")}</span></p>
            <p class="info">其他金额<span>+  ¥{:number_format($info['other_money'],2,".",",")}</span></p>
            <p class="bottom">应退款：<span>¥{:number_format($info['total_money'],2,".",",")}</span></p>
        </div>
        <ul class="productinfo" id="pro3">
            <p style="color: #666;">产品</p>
            {volist name="list" id="vo"}
            <li dataid="{$vo['shopid']}">
                <div class="infoleft"><img src="/plan/caigou/img/product.png"/></div>
                <div class="inforight">
                    <p>{$vo.cname}</p>
                    <p class="infop2">仓库：北京仓库</p>
                    <p class="infop3">¥{$vo.price}×<span id="znum{$vo['shopid']}">{$vo.num}</span>本</p>
                </div>
            </li>
            {/volist}

        </ul>
        {notempty name="worklist"}

        <ul class="list_info">
            <p class="title">审批流程</p>
            {volist name="worklist" id="vo"}

            <li>
                {if condition="$vo['status'] eq 2"}
                <img class="tx" src="/plan/caigou/img/bohui.jpg"/>
                {else}
                <img class="tx" src="/plan/caigou/img/ing.jpg"/>
                {/if}
                <p class="question">

                    <img src="{$vo['user']['avatar']}"/>

                    <span>{$vo['user']['username']} ·             {if condition="$vo['status'] eq 1"}
已通过 {elseif condition="$vo['status'] eq 2"}已驳回{else}审批中{/if}</span>
                </p>

                <p class="infodate">
                    {$vo.mark}
                </p>

            </li>

            {/volist}
        </ul>
        {/notempty}
        <div class="sug"  {in name="info['status']" value="9,8,7,6"}style="margin-top:0.2rem"{else}style="margin-top:0"{/in}>
        {in name="info['status']" value="9,8,7,6"}
        {in name="userid" value="$userArr"}

        <p class="titie">审批意见</p>
        <textarea style="height: 2rem;" id="mark"></textarea>
        {/in}

        {/in}
    </div>


    {if condition="$info['status'] eq 10 "}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>编辑</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="提交审核"/></div>
    </div>
    {/in}
    {elseif  condition="$info['status'] eq 9"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>驳回</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="通过"/></div>
    </div>
    {/in}
    {elseif  condition="$info['status'] eq 8"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>驳回</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="通过"/></div>
    </div>
    {/in}

    {elseif  condition="$info['status'] eq 5"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>编辑</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="作废"/></div>
    </div>
    {/in}
    {elseif  condition="$info['status'] eq 4"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>返回</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="添加"/></div>
    </div>
    {/in}
    {elseif  condition="$info['status'] eq 1"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>已完成</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="添加退货单"/></div>
    </div>
    {/in}
    {/if}


</section>
</body>
<script>
    var shopList={$jsList};
    var tempId;

    $(function () {

            $("#zbianji").click(function () {
                let data = JSON.parse($(this).attr("data-info"));
                switch (data.status){
                    case 10:
                        location.href="/index/retpur/edit/id/"+data.id;
                        break;
                    case 9:
                        examine(9);
                        break;
                    case 8:
                        examine(8);
                        break;

                    case 5:
                        location.href="/index/retpur/edit/id/"+data.id;
                        break;
                    case 4:
                        location.href="/index/retpur/index/";
                        break;
                    case 1:
                        location.href="/index/retpur/index/";
                        break;

                }
            });
            $("#tijiao").click(function () {

                let data = JSON.parse($(this).attr("data-info"));
                switch (data.status){
                    case 10:
                        //提交审核
                        oper(10);
                        break;
                    case 9:

                        oper(9);
                        break;
                    case 8:
                        oper(8);
                        break;

                    case 3:
                        oper(5);
                    case 2:
                        oper(2);
                    case 5:
                        oper(5);
                        break;
                    case 4:
                        location.href="/index/retpur/add/";
                        break;
                    case 1:
                        location.href="/index/retpur/add/";
                        break;
                }
            });
        })
    function oper(status) {
        if ($(".cgclose").hasClass("disabled") || $(".cgcontinue").hasClass("disabled")) return false;
        $(".cgclose,.cgcontinue").addClass("disabled");
        let mark = $("#mark").val();

        layer.open({type: 2,  shadeClose: false});
        $.ajax({
            type:"post",
            url:"/index/retpur/oper",
            data:{id:{$info['id']},status:status,mark:mark},
            success:function (data) {
                layer.closeAll();
                if (data.code==1){
                    layer.open({
                        content:'操作成功' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        location.reload();
                    },800);
                } else{
                    layer.open({
                        content:''+data.msg+'' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        window.location.href="/index/retpur/index"
                    },800);
                }
            }
        })
    }

    function examine(status) {
        if ($(".cgclose").hasClass("disabled") || $(".cgcontinue").hasClass("disabled")) return false;
        let mark = $("#mark").val();

        if (mark==''){
            layer.open({
                content:'请输入驳回意见' ,
                skin: 'msg',
                time: 2 //2秒后自动关闭
            });
            return false;
        }
        $(".cgclose,.cgcontinue").addClass("disabled");
        layer.open({type: 2,  shadeClose: false});

        $.ajax({
            type:"post",
            url:"/index/retpur/reject",
            data:{id:{$info['id']},status:status,mark:mark},
            success:function (data) {
                layer.closeAll();
                if (data.code==1){
                    layer.open({
                        content:'操作成功' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        location.reload();
                    },600);
                } else{
                    layer.open({
                        content:''+data.msg+'' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        window.location.href="/index/retpur/index"
                    },200);
                }

            }

        })
    }
</script>
</html>
